//
//  CYLoginVC.m
//  CarBabySitter
//
//  Created by hanzhiqiang on 2019/5/14.
//  Copyright © 2019年 1. All rights reserved.
//

#import "CYLoginVC.h"

@interface CYLoginVC ()

@end

@implementation CYLoginVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (IBAction)loginAction:(id)sender {
    if (self.userNameTextField.text.length<1) {
        [LoadingView showAMessage:@"请输入正确的用户名"];
        return;
    }
    
    
    if (self.passWordTextField.text.length<1) {
        [LoadingView showAMessage:@"请输入密码"];
        return;
    }
    [self.view endEditing:YES];
    
    [self savePwd];
    
    
    [self doLogin];
}
- (void)savePwd{
    NSString *info = [NSString stringWithFormat:@"%@|%@",self.userNameTextField.text,self.passWordTextField.text];
    NSString *path = [[AppManager documentDirectoryPath] stringByAppendingPathComponent:@"info.archive"];
    [NSKeyedArchiver archiveRootObject:info toFile:path];
    
}
-(void)doLogin{
    
//    NSString *url = @"user/public/login";
//
//    NSDictionary *par = @{
//                          @"username":_accountField.text,
//                          @"password":_pwdField.text,
//                          @"device_type":@"ios",
//                          };
//    [[Httprequest share] postObjectByParameters:par andUrl:url showLoading:YES showMsg:YES isFullUrk:NO andComplain:^(id obj) {
//
//        if (ISDIC(obj) && ISDIC(obj[@"data"]) && obj[@"data"][@"token"]) {
//            [self judgeLoginRes:obj[@"data"]];
//            CBUser *u = [[CBUser share]getMyInfo ];
//            u.user_type = obj[@"data"][@"user"][@"user_type"];
//            u.mobile = _accountField.text;
//            u.love_words = obj[@"data"][@"user"][@"love_words"];
//            u.liveness = obj[@"data"][@"user"][@"liveness"];
//
//            [u save];
//        }
//    } andError:^(id error) {
//
//    }];
    
}
- (IBAction)registerAction:(id)sender {
    
}
- (IBAction)forgetPassWordButtonClick:(id)sender {
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
